package com.lvmama.pojo.dto.rhino.system;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.lvmama.pojo.entity.rhino.system.Role;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Getter
@Setter
@ToString
public class UserDTO implements Serializable {
    private static final long serialVersionUID = -6993801235194804384L;

    /**
     * 主键
     */
    private String id;

    /**
     * 登录名
     */
    private String loginName;

    /**
     * 密码
     */
    private String password;

    /**
     * 中文名
     */
    private String name;

    /**
     * 邮箱地址
     */
    private String email;

    /**
     * 手机号码
     */
    private String phone;

    /**
     * 是否可登录
     */
    private String isEnable;

    /**
     * 最后登录IP
     */
    private String loginIp;

    /**
     * 最后登陆时间
     */
    private Date loginDate;

    /**
     * 备注
     */
    private String remarks;

    /**
     * 删除标志
     */
    private String delFlag;

    /**
     * 重置密码标志
     */
    private String isReset;

    private List<Role> roles = new ArrayList<>();

    private List<String> roleIds;

    @JsonIgnore
    public List<String> getRoleIdList() {
        List<String> roleIdList = new ArrayList<>();
        for (Role role : roles) {
            roleIdList.add(role.getId());
        }
        return roleIdList;
    }

    @JsonIgnore
    public void setRoleIdList(List<String> roleIdList) {
        roles = new ArrayList<>();
        for (String roleId : roleIdList) {
            Role role = new Role();
            role.setId(roleId);
            roles.add(role);
        }
    }

}
